#!/usr/bin/env node

class EventEmitter {
  constructor() {
    this.#listeners = {};
  }
  on(evtName, cb) {
    if(typeof(this.#listeners[evtName]) === 'undefined') {
      this.#listeners[evtName] = [];
    }

    this.#listeners[evtName].push(cb);
  }

  emit(evtName, arg) {
      for(let k=0;k<this.#listeners[evtName].length;k++) {
        this.#listeners[evtName][k](arg);
      }

  }

  #listeners = null;
}

module.exports = {EventEmitter};

